#!/bin/bash -e

if [ $# -lt 2 ]; then
  echo "$0 <src dir> <dst dir>"
  exit 1
fi

dir=$1
dst=$2

ls ${dir}/*.rpm | while read i;
do
   pkg=$(basename $i)
   echo "processs package $pkg ..."
   name=$(rpm -qp --queryformat "%{NAME}" ${dir}/${pkg})
   # echo "copy $pkg to ${dst}/${name}.rpm ..."
   cp -v ${dir}/${pkg} ${dst}/${name}.rpm
done
